﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Billing.WindowsBase.CustomControls
{
    public delegate void ButtonClickHandler(object sender);

    [ToolboxItem(false)]
    public partial class BaseControl : UserControl
    {
        public BaseControl()
        {
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            InitializeComponent();
        }
        public bool CaptionVisibled
        {
            get { return this.lblCaption.Visible; }
            set { this.lblCaption.Visible = value; }
        }
        public string Caption
        {
            get { return this.lblCaption.Text; }
            set { this.lblCaption.Text = value; }
        }



        #region Label

        public virtual string LabelText
        {
            get { return null; }
            set { ; }
        }

        public virtual Size LabelSize
        {
            get { return this.Size; }
            set { ; }
        }

        public virtual bool LabelVisible
        {
            get { return this.Visible; }
            set { ; }
        }

        private bool mLabelAutoSize = false;

        public virtual bool LabelAutoSize
        {
            get { return mLabelAutoSize; }
            set { mLabelAutoSize = value; }
        }

        public virtual Color LabelBorderColor
        {
            get { return this.BackColor; }
            set { ; }
        }
        #endregion
        public virtual event ButtonClickHandler KeyUpEvent;
        public virtual event EventHandler ControlValueChanged;
        #region Editor
        public virtual string EditorText
        {
            get { return null; }
            set { ; }
        }

        public virtual Size EditorSize
        {
            get { return this.Size; }
            set { ; }
        }

        public virtual bool EditorVisible
        {
            get { return this.Visible; }
            set { ; }
        }

        public virtual Object EditorSource
        {
            get { return null; }
            set { ; }
        }

        public virtual object EditorValue
        {
            get { return null; }
            set { ; }
        }

        public virtual bool EditorIsReadOnly
        {
            get { return false; }
            set { ; }
        }

        public virtual string EditorFormat
        {
            get { return null; }
            set { ; }
        }

        public virtual string EditorMask
        {
            get { return null; }
            set { ; }
        }
        private string mEditorType;
        public virtual string EditorType
        {
            get { return mEditorType; }
            set { mEditorType = value; }
        }
        private int? mEditorKeyUpEventKey = null;
        [Category("Custom")]
        public virtual int? EditorKeyUpEventKey
        {
            get { return mEditorKeyUpEventKey; }
            set { mEditorKeyUpEventKey = value; }
        }
        #endregion

        protected void ShowError(Exception x)
        {
            MessageBox.Show(BillingException.ConvertFromException(x).Message, "შეცდომა", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        protected void ShowInformation(string message)
        {
            MessageBox.Show(message, "ინფორმაცია", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        protected void ShowWarning(string message)
        {
            MessageBox.Show(message, "გაფრთხილება", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        protected DialogResult ShowQuestion(string message)
        {
            return ShowQuestion(message, MessageBoxButtons.YesNo);
        }

        protected DialogResult ShowQuestion(string message, MessageBoxButtons messageBoxButtons)
        {
            return MessageBox.Show(message, "დაადასტურეთ", messageBoxButtons, MessageBoxIcon.Question);
        }

    }
}
